package Test_0813;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 * Dare: 2024-08-13
 * Time: 17:08
 */
public class Student  {
    public int age;
    public String name;

    public Student(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    //@Override
    public int compareTo(Student o) {
     /*   //比较年龄
        //大于返回1；
        if(this.age>o.age){
            return 1;
        }
        //小于返回-1
        else if(this.age<o.age){
            return -1;
        }
        //等于返回o
        else{
            return 0;
        }*/
       /* return this.age-o.age;*/
        return this.name.compareTo(o.name);
    }
}
